﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 真空印刷机定位视觉系统.窗口
{
    public partial class Frm_Login : Form
    {

        private Hashtable Level_hash  = new Hashtable ();
        public AcessLevel Level = AcessLevel.操作员;


        public Frm_Login()
        {
            InitializeComponent();
        }

        private void OK_Click(object sender, EventArgs e)
        {
            Level_Password levelPassword =  this.Level_hash[ComboBox1.SelectedIndex] as Level_Password;
            if (levelPassword != null)
            {
                if (levelPassword.Password ==  Txt_Password.Text.Trim()  )
                {
                    Level = levelPassword.Level;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    Txt_Password.Text = "";
                    MessageBox.Show("密码错误！");
                }
             
            }
        }

        private void Frm_Login_Load(object sender, EventArgs e)
        {
            Level_hash.Add(0, new Level_Password(AcessLevel.工程师, "123"));
            Level_hash.Add(1, new Level_Password(AcessLevel.开发者, "456"));
            Level_hash.Add(2, new Level_Password(AcessLevel.Admin, "123456"));
            ComboBox1.SelectedIndex = 0;
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            //this.Close();
        }
    }


     public class Level_Password
    {
        public AcessLevel Level;
        public string Password;
        public Level_Password(AcessLevel level , string Password)
        {
            this.Level = level;
            this.Password = Password;
        }
    }
     
}
